/**
 * File:   Example.java
 * Author: Gvennet
 */
package dht.async;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.DelayQueue;
import java.util.Random;
import java.util.List;
import java.util.Queue;

/** todo write javadoc */
public class Example
{

    public static void main(String[] args)
    {
        BlockingQueue q = new LinkedBlockingQueue<Runnable>();
        Executor e =  new ThreadPoolExecutor(20, 20, 0, TimeUnit.MINUTES, q);
        Communicator c = new Communicator(e);


        Node node = new DemoNode(c);
//        System.out.println(node.getIdentifier());

        for (int i=0; i<1000; i++)
        {
            Node newNode = new DemoNode(c);
//            System.out.println(newNode.getIdentifier());
            Message m = new Message(0, node, newNode, null);
            c.sendMessage(m);
        }

        Node source = new DemoNode(c);
        Node target = new DemoNode(c);
        Message findNode = new Message (2, node, source, target);
        c.sendMessage(findNode);

        




    }
}

